import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter);

import Test1 from "../components/Login/Test1";
import Test2 from "../components/Login/Test2";
import Info from "../components/Info";
const routes = [
  {
    path: '/login',
    component: Test1,
    name:"login"
  },
  {
    path: '/index',
    component: Test2,
    name:"index"
  },
  {
    path:'/info',
    component:Info,
    name:"info"
  }
];

const router = new VueRouter({
  mode: 'history',
  base: "/test2/",
  routes
});

router.beforeEach((to,from,next) => {
  if(to.name === 'info' && from.name!=='login') next({name:'login'});
  next()
});
export default router
